<template>
  <div class="head">
    <nav>
      <div class="a-topBar">
        <div class="a-logo">
          <img id="ico" alt="icon" src="@/assets/logo.png">
        </div>
        <div class="a-links">
          <div class="a-block">
            <div class="a-home">
              <router-link class="s-font-nav_item s-nav-text" to="/"> 主页 </router-link>
            </div>
          </div>
          <div class="a-block">
            <div class="a-about">
              <router-link class="s-font-nav_item s-nav-text" to="/about"> 关于 </router-link>
            </div>
          </div>
          <div class="a-block">
            <div class="a-news">
              <router-link class="s-font-nav_item s-nav-text" to="/news"> 新闻 </router-link>
            </div>
          </div>
          <div class="a-block">
            <div class="a-login">
              <router-link class="s-font-nav_item s-nav-text" to="/login"> 登陆 </router-link>
            </div>
          </div>
        </div>
        <div class="a-user">
          <el-avatar>user</el-avatar>
          <h4>{{user.name}}</h4>
        </div>
      </div>
      <router-view/>
    </nav>
  </div>
</template>

<script>
export default {
  data() {
    return {
      user: {
        name: '未登录'
      },
    };
  },
  mounted() {
    this.load();
  },
  methods: {
    load() {
      if(sessionStorage.getItem("user") && this.user.name==='未登录')
      {
        let users = JSON.parse(sessionStorage.getItem("user"))
        this.user = users
        console.log(this.user)
      }
    }
  }
}
</script>

<style>
#ico{
  width: 216px;
  height: 120px;
}

.a-topBar{
  margin: auto;
  height: 100px;
  background-color: #2c3e50;
  display: flex;
  border-bottom-style:dotted;
}

.a-links{
  position: absolute;
  left: 50%;
  transform: translate(-50%,85%);
  width: 100%;
  height: 36px;
  font-size: 18px;
  display: flex;
  justify-content: center;
}

.a-block{
  padding: 10px 7px;
}

.a-user{
  position: absolute;
  height: 50px;
  width: 150px;
  right: 0px;
  display: flex;
  justify-content: center;
  transform: translate(0%,50%);
}

#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  top: 0px;
}

nav {
  max-width: 100%;
}

nav a {
  font-weight: bold;
  text-decoration: none;
  color: aliceblue;
}

nav a.router-link-exact-active {
  font-weight: bold;
  text-decoration: underline;
  color: aliceblue;
}

</style>